package com.LLL.customer.service;

import com.LLL.customer.dao.CustomerDao;
import com.LLL.customer.model.Customer;

public class CustomerService {
    /** 根据账号密码返回会员信息 --登录 */
    public Customer login(String username, String password) {
        CustomerDao dao= new CustomerDao();
        Customer customer = dao.getCustomerByName(username);
        if(customer != null){
            if(username.equals(customer.getUser_name()) && password.equals(customer.getPassword()) ){
                return customer;
            }
        }
        return null;
    }

    public boolean register(String username, String password) {
        if(username == null || "".equals(username) || password == null || "".equals(password)){
            return false;
        }
        CustomerDao dao = new CustomerDao();
        //调用Dao层的逻辑进行全员注册
        int result = dao.addCustomer(username,password);
        return  result > 0;
    }
}
